package com.fsnbigdata.demo;

import com.fsnbigdata.domain.*;
import com.fsnbigdata.domain.security.Authority;
import com.fsnbigdata.domain.security.User;
import com.fsnbigdata.service.api.*;
import io.springlets.data.domain.GlobalSearch;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhongcheng on 25/09/2017.
 */
@Configuration
public class DemoData {

    @Bean
    public CommandLineRunner userDemo(UserService userService) {
        return (args) -> {
            BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();

            User check1 = userService.findByUsername("shengwusuo");

            if (check1 == null) {
                User user1 = new User();
                user1.setUsername("shengwusuo");
                user1.setName("生物所");
                user1.setPassword(passwordEncoder.encode("123456"));
                List authorities = new ArrayList<Authority>();
                authorities.add(new Authority("ROLE_USER_ADMIN"));
                authorities.add(new Authority("ROLE_USER"));
                authorities.add(new Authority("ROLE_DB_ORGANISM"));
                authorities.add(new Authority("ROLE_DB_SPECIMEN"));
                authorities.add(new Authority("ROLE_DB_ECOSYSTEM"));

                userService.save(user1);
            }

            User check12 = userService.findByUsername("lilei");
            if (check12 == null) {

                User user12 = new User();
                user12.setUsername("lilei");
                user12.setName("李雷");
                user12.setPassword(passwordEncoder.encode("123456"));
                List authorities12 = new ArrayList<Authority>();
                authorities12.add(new Authority("ROLE_USER"));
                authorities12.add(new Authority("ROLE_DB_ORGANISM"));
                authorities12.add(new Authority("ROLE_DB_SPECIMEN"));
                authorities12.add(new Authority("ROLE_DB_ECOSYSTEM"));
                authorities12.add(new Authority("ROLE_DB_DOCUMENT"));
                authorities12.add(new Authority("ROLE_DB_ZHKOPP"));   //科普权限
                authorities12.add(new Authority("ROLE_DB_ZHECOLOGYNAV"));   //生态旅游权限
                authorities12.add(new Authority("ROLE_DB_DIVERSITYREPORT"));   //多样性报告权限
                authorities12.add(new Authority("ROLE_DB_ZHEXPERT"));   //专家咨询权限
                user12.setAuthorities(authorities12);
                user12.getAuthorities().stream().forEach(it -> ((Authority) it).setUser(user12));
                user12.setEnabled(true);

                userService.save(user12);
            }

            User check2 = userService.findByUsername("zhiwuyuan");
            if (check2 == null) {
                User user2 = new User();
                user2.setUsername("zhiwuyuan");
                user2.setName("植物园");
                user2.setPassword(passwordEncoder.encode("123456"));
                List authorities2 = new ArrayList<Authority>();
                authorities2.add(new Authority("ROLE_USER_ADMIN"));
                authorities2.add(new Authority("ROLE_USER"));
                authorities2.add(new Authority("ROLE_DB_PARK"));
                authorities2.add(new Authority("ROLE_DB_ES_CS"));
                authorities2.add(new Authority("ROLE_DB_VEGETATION"));
                user2.setAuthorities(authorities2);
                user2.getAuthorities().stream().forEach(it -> ((Authority) it).setUser(user2));
                user2.setEnabled(true);

                userService.save(user2);
            }


            User check21 = userService.findByUsername("hanmeimei");
            if (check21 == null) {
                User user21 = new User();
                user21.setUsername("hanmeimei");
                user21.setName("韩梅梅");
                user21.setPassword(passwordEncoder.encode("123456"));
                List authorities21 = new ArrayList<Authority>();
                authorities21.add(new Authority("ROLE_USER"));
                authorities21.add(new Authority("ROLE_DB_PARK"));
                authorities21.add(new Authority("ROLE_DB_ES_CS"));
                authorities21.add(new Authority("ROLE_DB_VEGETATION"));
                user21.setAuthorities(authorities21);
                user21.getAuthorities().stream().forEach(it -> ((Authority) it).setUser(user21));
                user21.setEnabled(true);

                userService.save(user21);
            }

            User check31 = userService.findByUsername("kexueyuan");
            if (check31 == null) {
                User user31 = new User();
                user31.setUsername("kexueyuan");
                user31.setName("科学院");
                user31.setPassword(passwordEncoder.encode("123456"));

                List adminAuthorities = new ArrayList<Authority>();
                adminAuthorities.add(new Authority("ROLE_USER_ADMIN"));
                adminAuthorities.add(new Authority("ROLE_USER"));
                adminAuthorities.add(new Authority("ROLE_DB_PRODUCT"));
                adminAuthorities.add(new Authority("ROLE_DB_ENTERPRISE"));

                user31.setAuthorities(adminAuthorities);
                user31.getAuthorities().stream().forEach(it -> ((Authority) it).setUser(user31));
                user31.setEnabled(true);

                userService.save(user31);
            }

            User check32 = userService.findByUsername("xiaoming");
            if (check32 == null) {
                User user32 = new User();
                user32.setUsername("xiaoming");
                user32.setName("小明");
                user32.setPassword(passwordEncoder.encode("123456"));

                List adminAuthorities = new ArrayList<Authority>();
                adminAuthorities.add(new Authority("ROLE_USER"));
                adminAuthorities.add(new Authority("ROLE_DB_PRODUCT"));
                adminAuthorities.add(new Authority("ROLE_DB_ENTERPRISE"));

                user32.setAuthorities(adminAuthorities);
                user32.getAuthorities().stream().forEach(it -> ((Authority) it).setUser(user32));
                user32.setEnabled(true);

                userService.save(user32);
            }

            User checkAdmin = userService.findByUsername("admin");
            if (checkAdmin == null) {
                User admin = new User();
                admin.setUsername("admin");
                admin.setName("管理员");
                admin.setPassword(passwordEncoder.encode("123456"));

                List adminAuthorities = new ArrayList<Authority>();
                adminAuthorities.add(new Authority("ROLE_USER_ADMIN"));
                adminAuthorities.add(new Authority("ROLE_USER"));
                adminAuthorities.add(new Authority("ROLE_DB_ORGANISM"));
                adminAuthorities.add(new Authority("ROLE_DB_SPECIMEN"));
                adminAuthorities.add(new Authority("ROLE_DB_ECOSYSTEM"));
                adminAuthorities.add(new Authority("ROLE_DB_PARK"));
                adminAuthorities.add(new Authority("ROLE_DB_ES_CS"));
                adminAuthorities.add(new Authority("ROLE_DB_VEGETATION"));
                adminAuthorities.add(new Authority("ROLE_DB_PRODUCT"));
                adminAuthorities.add(new Authority("ROLE_DB_ENTERPRISE"));
                adminAuthorities.add(new Authority("ROLE_DB_DOCUMENT"));
                adminAuthorities.add(new Authority("ROLE_DB_LOG"));   //日志权限
                adminAuthorities.add(new Authority("ROLE_DB_ZHKOPP"));   //科普权限
                adminAuthorities.add(new Authority("ROLE_DB_ZHECOLOGYNAV"));   //生态旅游权限
                adminAuthorities.add(new Authority("ROLE_DB_DIVERSITYREPORT"));   //多样性报告权限
                adminAuthorities.add(new Authority("ROLE_DB_ZHEXPERT"));   //专家咨询权限
                adminAuthorities.add(new Authority("ROLE_DB_ZHHELP"));   //帮助权限

//                adminAuthorities.add(new Authority("ROLE_DB_ZHCOLOGY"));
//                adminAuthorities.add(new Authority("ROLE_DB_ZHDIVREPORT"));
//                adminAuthorities.add(new Authority("ROLE_DB_ZHKOPP"));
//                adminAuthorities.add(new Authority("ROLE_DB_ZHEXPERT"));
//                adminAuthorities.add(new Authority("ROLE_DB_ZHHELP"));

                admin.setAuthorities(adminAuthorities);
                admin.getAuthorities().stream().forEach(it -> ((Authority) it).setUser(admin));
                admin.setEnabled(true);

                userService.save(admin);
            }

            User kuankuoshui = userService.findByUsername("kuankuoshui");
            if (kuankuoshui == null) {
                User user32 = new User();
                user32.setUsername("kuankuoshui");
                user32.setName("宽阔水");
                user32.setEmail("132@qq.com");     //没有拿到邮箱，暂时使用假的
                user32.setPassword(passwordEncoder.encode("123456.qw"));

                List adminAuthorities = new ArrayList<Authority>();
                adminAuthorities.add(new Authority("ROLE_USER_ADMIN"));
                adminAuthorities.add(new Authority("ROLE_USER"));
                adminAuthorities.add(new Authority("ROLE_DB_DIVERSITYREPORT"));   //多样性报告权限

                user32.setAuthorities(adminAuthorities);
                user32.getAuthorities().stream().forEach(it -> ((Authority) it).setUser(user32));
                user32.setEnabled(true);

                userService.save(user32);
            }

            User mayanghe = userService.findByUsername("mayanghe");
            if (mayanghe == null) {
                User user32 = new User();
                user32.setUsername("mayanghe");
                user32.setName("麻阳河");
                user32.setEmail("132@qq.com");     //没有拿到邮箱，暂时使用假的
                user32.setPassword(passwordEncoder.encode("123456.qw"));

                List adminAuthorities = new ArrayList<Authority>();
                adminAuthorities.add(new Authority("ROLE_USER_ADMIN"));
                adminAuthorities.add(new Authority("ROLE_USER"));
                adminAuthorities.add(new Authority("ROLE_DB_DIVERSITYREPORT"));   //多样性报告权限

                user32.setAuthorities(adminAuthorities);
                user32.getAuthorities().stream().forEach(it -> ((Authority) it).setUser(user32));
                user32.setEnabled(true);

                userService.save(user32);
            }

            User maolan = userService.findByUsername("maolan");
            if (maolan == null) {
                User user32 = new User();
                user32.setUsername("maolan");
                user32.setName("茂兰");
                user32.setEmail("132@qq.com");     //没有拿到邮箱，暂时使用假的
                user32.setPassword(passwordEncoder.encode("123456.qw"));

                List adminAuthorities = new ArrayList<Authority>();
                adminAuthorities.add(new Authority("ROLE_USER_ADMIN"));
                adminAuthorities.add(new Authority("ROLE_USER"));
                adminAuthorities.add(new Authority("ROLE_DB_DIVERSITYREPORT"));   //多样性报告权限

                user32.setAuthorities(adminAuthorities);
                user32.getAuthorities().stream().forEach(it -> ((Authority) it).setUser(user32));
                user32.setEnabled(true);

                userService.save(user32);
            }

//            User csAdmin = userService.findByUsername("csAdmin");
//            if (csAdmin == null) {
//                User admin = new User();
//                admin.setUsername("csadmin");
//                admin.setName("测试管理员");
//                admin.setEmail("1325423@qq.com");
//                admin.setPassword(passwordEncoder.encode("123456.qw"));
//
//                List adminAuthorities = new ArrayList<Authority>();
//                adminAuthorities.add(new Authority("ROLE_USER_ADMIN"));
//                adminAuthorities.add(new Authority("ROLE_USER"));
//                adminAuthorities.add(new Authority("ROLE_DB_LOG"));   //日志权限
//
//                adminAuthorities.add(new Authority("ROLE_DB_ZHHELP"));   //帮助权限
//
////                adminAuthorities.add(new Authority("ROLE_DB_ZHCOLOGY"));
////                adminAuthorities.add(new Authority("ROLE_DB_ZHDIVREPORT"));
////                adminAuthorities.add(new Authority("ROLE_DB_ZHKOPP"));
////                adminAuthorities.add(new Authority("ROLE_DB_ZHEXPERT"));
////                adminAuthorities.add(new Authority("ROLE_DB_ZHHELP"));
//
//                admin.setAuthorities(adminAuthorities);
//                admin.getAuthorities().stream().forEach(it -> ((Authority) it).setUser(admin));
//                admin.setEnabled(true);
//
//                userService.save(admin);
//            }

//            User check3 = userService.findByUsername("zhangxiaofeng");
//            if (check3 == null) {
//                User user3 = new User();
//                user3.setUsername("zhangxiaofeng");
//                user3.setName("张晓锋");
//                user3.setPassword(passwordEncoder.encode("123456"));
//                List authorities3 = new ArrayList<Authority>();
//                authorities3.add(new Authority( "ROLE_USER_ADMIN"));
//                authorities3.add(new Authority( "ROLE_DB_ORGANISM"));
//                authorities3.add(new Authority( "ROLE_DB_SPECIMEN"));
//                authorities3.add(new Authority( "ROLE_DB_ECOSYSTEM"));
//                authorities3.add(new Authority( "ROLE_USER"));
//                authorities3.add(new Authority( "ROLE_DB_PARK"));
//                authorities3.add(new Authority( "ROLE_DB_ES_CS"));
//                user3.setAuthorities(authorities3);
//                user3.getAuthorities().stream().forEach(it-> ((Authority)it).setUser(user3));
//                user3.setEnabled(true);
//
//                userService.save(user3);
//            }
//
//            User check4 = userService.findByUsername("yangjiajian");
//            if (check4 == null) {
//                User user3 = new User();
//                user3.setUsername("yangjiajian");
//                user3.setName("杨佳健");
//                user3.setPassword(passwordEncoder.encode("123456"));
//                List authorities3 = new ArrayList<Authority>();
//                authorities3.add(new Authority( "ROLE_USER_ADMIN"));
//                authorities3.add(new Authority( "ROLE_DB_ORGANISM"));
//                authorities3.add(new Authority( "ROLE_DB_SPECIMEN"));
//                authorities3.add(new Authority( "ROLE_DB_ECOSYSTEM"));
//                authorities3.add(new Authority( "ROLE_USER"));
//                authorities3.add(new Authority( "ROLE_DB_PARK"));
//                authorities3.add(new Authority( "ROLE_DB_ES_CS"));
//                user3.setAuthorities(authorities3);
//                user3.getAuthorities().stream().forEach(it-> ((Authority)it).setUser(user3));
//                user3.setEnabled(true);
//
//                userService.save(user3);
//            }
        };
    }

    @Bean
    public CommandLineRunner organismDemo(OrganismService organismService) {
        return (args) -> {
            GlobalSearch globalSearch = new GlobalSearch("中华猕猴桃");
            Page<Organism> check = organismService.findAll(globalSearch, new PageRequest(0, 20));
            if (check.hasContent()) {
                return;
            }

            com.fsnbigdata.domain.Organism organism = new com.fsnbigdata.domain.Organism();
            //http://iflora.cn/search_result.aspx?p=D5C5D0C072DB130DB20811AFBCE7D005#toc2
            organism.setCreator("lilei");
            organism.setName("中华猕猴桃");
            organism.setLatinName("Actinidia chinensis");
            organism.setAlias("阳桃，羊桃，羊桃藤，藤梨，猕猴桃");
            organism.setNamedInfo("1997 未知");
            organism.setHabitat("森林|陆地");
            organism.setEndemism("中国特有|贵州特有");
            organism.setCharacteristic("大型落叶藤本；幼一枝或厚或薄地被有灰白色茸毛或褐色长硬毛或铁锈色硬毛状刺毛，老时秃净或留有断损残毛；花枝短的4-5厘米，长的15-20厘米，直径4-6毫米；隔年枝完全秃净无毛，直径5-8毫米，皮孔长圆形，比较显著或不甚显著；髓白色至淡褐色，片层状。叶纸质，倒阔卵形至倒卵形或阔卵形至近圆形，长6-17厘米，宽7-15厘米，顶端截平形并中间凹入或具突尖、急尖至短渐尖，基部钝圆形、截平形至浅心形，边缘具脉出的直伸的睫状小齿，腹面深绿色，无毛或中脉和侧脉上有少量软毛或散被短糙毛，背面苍绿色，密被灰白色或淡褐色星状绒毛，侧脉5-8对，常在中部以上分歧成叉状，横脉比较发达，易见，网状小脉不易见；叶柄长3-6(-10)厘米，被灰白色茸毛或黄褐色长硬毛或铁锈色硬毛状刺毛。聚伞花序1-3花，花序柄长7-15毫米，花柄长9-15毫米；苞片小，卵形或钻形，长约1毫米，均被灰白色丝状绒毛或黄褐色茸毛；花初放时白色，放后变淡黄色，有香气，直径1.8-3.5厘米；萼片3-7片，通常5片，阔卵形至卵状长圆形，长6-10毫米，两面密被压紧的黄褐色绒毛；花瓣5片，有时少至3-4片或多至6-7片，阔倒卵形，有短距，长10-20毫米，宽6-17毫米；雄蕊极多，花丝狭条形，长5-10毫米，花药黄色，长圆形，长1.5-2毫米，基部叉开或不叉开；子房球形，径约5毫米，密被金黄色的压紧交织绒毛或不压紧不交织的刷毛状糙毛，花柱狭条形。果黄褐色，近球形、圆柱形、倒卵形或椭圆形，长4-6厘米，被茸毛、长硬毛或刺毛状长硬毛，成熟时秃净或不秃净，具小而多的淡褐色斑点；宿存萼片反折；种子纵径2.5毫米。");
            organism.setUseValues("【苗药】功用同洋桃《苗医药》。 Ghab jiongx zangd git gheib（嘎龚姜格给）：根用于补虚，祛风止痛，除湿《苗药集》。藤梨果：根用于风湿性关节炎，淋巴结核，跌打损伤，痈疖《湘蓝考》。【畲药】胡毛党，白毛桃，犬蛋袋，胡毛猪仔：根、叶治偏坠，脱肛，遗精，白浊，黄疸，痢疾《畲医药》。【壮药】冬兵，冬耐：根用于补气健胃《桂药编》。【侗药】冬因，羊桃，登已挂：功用同壮族《桂药编》。根、叶治水肿，消化不良，胎盘滞留[25]。【土家药】根或根皮治肝炎，水肿，跌打损伤，风湿关节痛，乳汁不足，淋浊，带下，疮疖，瘰疬[203]");

            Taxonomy taxonomy = new Taxonomy();
            taxonomy.setKingdom("植物界");
            taxonomy.setKingdomLatin("Plantae");
            taxonomy.setPhylumn("被子植物门");
            taxonomy.setPhylumnLatin("Angiospermae");
            taxonomy.setTClass("原始花被亚纲");
            taxonomy.setTClassLatin("Archichlamydeae");
            taxonomy.setTOrder("五桠果亚目");
            taxonomy.setTOrderLatin("Dilleniineae");
            taxonomy.setFamily("猕猴桃科");
            taxonomy.setFamilyLatin("Actinidiaceae");
            taxonomy.setGenus("猕猴桃属");
            taxonomy.setGenusLatin("Actinidia");
            taxonomy.setSpecies("中华猕猴桃");
            taxonomy.setSpeciesLatin("Actinidia chinensis");
            organism.getTaxonomy().add(taxonomy);
            organism.getTaxonomy().forEach(it -> it.setOrganism(organism));

            OrganismImage image1 = new OrganismImage();
            image1.setUrl("http://iflora.cn/gbnew/IF/2008photos/%e5%b9%b3%e5%8f%b0%e9%a1%b9%e7%9b%ae/%e5%88%98%e5%85%8b%e6%98%8e/public/SCSB-HN-1715/%e5%b0%8f%e7%94%9f%e5%a2%83.JPG");
            organism.getImages().add(image1);
            OrganismImage image2 = new OrganismImage();
            image2.setUrl("http://iflora.cn/gbnew/IF/2008photos/%e5%b9%b3%e5%8f%b0%e9%a1%b9%e7%9b%ae/%e5%88%98%e5%85%8b%e6%98%8e/public/SCSB-HN-1715/%e6%9e%9c%e5%ae%9e.JPG");
            organism.getImages().add(image2);
            OrganismImage image3 = new OrganismImage();
            image3.setUrl("http://iflora.cn/search_result.aspx?p=D5C5D0C072DB130DB20811AFBCE7D005#toc2");
            organism.getImages().add(image3);
            organism.getImages().forEach(it -> it.setOrganism(organism));

            Distribution distribution1 = new Distribution();
            distribution1.setCountry("中国");
            distribution1.setCity("重庆");
            distribution1.setProvince("重庆");
            distribution1.setDetail("三泉镇大河村黄草坪金佛山景区");
            organism.getDistribution().add(distribution1);

            Distribution distribution2 = new Distribution();
            distribution2.setCountry("中国");
            distribution2.setCity("娄底市");
            distribution2.setProvince("湖南省");
            distribution2.setDetail("大熊山林场高峰工区五组");
            organism.getDistribution().add(distribution2);

            organism.getDistribution().forEach(it -> it.setOrganism(organism));

            OrganismDocument document1 = new OrganismDocument();
            document1.setName("《中国民族药志要》1997年");
            document1.setAuthor("贾敏如、李星炜");

            organism.getDocuments().add(document1);
            organism.getDocuments().forEach(it -> it.setOrganism(organism));

            Germplasm germplasm1 = new Germplasm();
            germplasm1.setPreserveNo("868710199875");
            germplasm1.setUnit("北京大学");
            germplasm1.setOwner("沈泽昊");
            germplasm1.setCollectNo("ShenZH5772");
            germplasm1.setCollector("祝文志、刘志祥、曹远俊");
            germplasm1.setCollectDate("2010-10-09");
            germplasm1.setCollectLocation("中国湖北省宜昌市长阳土家族自治县");
            germplasm1.setResourceType("种子");
            organism.getGermplasm().add(germplasm1);
            organism.getGermplasm().forEach(it -> it.setOrganism(organism));

            ConservationStatus conservationStatus = new ConservationStatus();
            conservationStatus.setName("中国濒危植物名录");
            conservationStatus.setStatus("无危");
            organism.getConservationStatus().add(conservationStatus);
            organism.getConservationStatus().forEach(it -> it.setOrganism(organism));

            organismService.save(organism);
        };
    }

    @Bean
    public CommandLineRunner specimenDemo(SpecimenService specimenService) {
        return (args) -> {
            GlobalSearch globalSearch = new GlobalSearch("中华猕猴桃");
            Page<Specimen> check = specimenService.findAll(globalSearch, new PageRequest(0, 20));
            if (check.hasContent()) {
                return;
            }

            Specimen specimen = new Specimen();

            //http://db.kun.ac.cn/speciman/show/identid/736453
            specimen.setCreator("lilei");
            specimen.setName("中华猕猴桃");
            specimen.setCollectNumber("GLM-07652");
            specimen.setCollectPerson("高连明,吴丁");
            specimen.setCollectCoordinate("");
            specimen.setCollectLocation("云南省,昭通市,威信县");
            specimen.setCollectDate("2007-05-20");

            SpecimenImage image1 = new SpecimenImage();
            image1.setUrl("http://f0.kun.ac.cn/image_01/5/2016_03_31/8ec3e841bda2714b_5_1459418483.jpg");
            specimen.getImages().add(image1);
            specimen.getImages().forEach(it -> it.setSpecimen(specimen));

            specimenService.save(specimen);
        };
    }

    //@Bean TODO we dont need this demo data anymore
    public CommandLineRunner parksDemo(ParkService parkService) {
        return (args) -> {
            GlobalSearch globalSearch = new GlobalSearch("纽约中央公园");
            Page<Park> check = parkService.findAll(globalSearch, new PageRequest(0, 20));
            if (check.hasContent()) {
                return;
            }

            //https://en.wikipedia.org/wiki/Central_Park
            Park park = new Park();
            park.setCreator("lilei");
            park.setName("纽约中央公园");
            park.setImage("https://upload.wikimedia.org/wikipedia/commons/thumb/b/b2/Location_map_United_States_Manhattan.png/272px-Location_map_United_States_Manhattan.png");

            ParkDistrict parkDistrict1 = new ParkDistrict();
            parkDistrict1.setName("The Lake");
            parkDistrict1.setDescription("The Lake and San Remo apartments in the background");
            parkDistrict1.setImage("https://upload.wikimedia.org/wikipedia/commons/e/e5/Central_Park_Lake_%26_San_Remo.jpg");
            park.getDistricts().add(parkDistrict1);

            ParkDistrictOrganism parkDistrictOrganism11 = new ParkDistrictOrganism();
            parkDistrictOrganism11.setName("红尾鵟");
            parkDistrictOrganism11.setLatinName("B. jamaicensis");
            parkDistrictOrganism11.setImage("https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/Red-tailed_Hawk_Buteo_jamaicensis_Full_Body_1880px.jpg/240px-Red-tailed_Hawk_Buteo_jamaicensis_Full_Body_1880px.jpg");
            ParkDistrictOrganismImage parkDistrictOrganismImage11 = new ParkDistrictOrganismImage();
            parkDistrictOrganismImage11.setUrl("https://upload.wikimedia.org/wikipedia/commons/thumb/9/9b/Red-tailed_Hawk_Buteo_jamaicensis_Full_Body_1880px.jpg/240px-Red-tailed_Hawk_Buteo_jamaicensis_Full_Body_1880px.jpg");
            parkDistrictOrganism11.getImages().add(parkDistrictOrganismImage11);
            parkDistrictOrganism11.getImages().forEach(it -> it.setParkDistrictOrganism(parkDistrictOrganism11));
            parkDistrict1.getOrganisms().add(parkDistrictOrganism11);
            parkDistrict1.getOrganisms().forEach(it -> it.setParkDistrict(parkDistrict1));

            ParkDistrict parkDistrict2 = new ParkDistrict();
            parkDistrict2.setName("Lower Central Park");
            parkDistrict2.setDescription("Lower Central Park");
            parkDistrict2.setImage("https://upload.wikimedia.org/wikipedia/commons/thumb/5/51/Lower_Central_Park_Shot_3.JPG/270px-Lower_Central_Park_Shot_3.JPG");
            park.getDistricts().add(parkDistrict2);
            ParkDistrictOrganism parkDistrictOrganism21 = new ParkDistrictOrganism();
            parkDistrictOrganism21.setName("浣熊");
            parkDistrictOrganism21.setLatinName("P. lotor");
            parkDistrictOrganism21.setImage("https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/0_Procyon_lotor_-_Raton_laveur_commun_%281%29.JPG/250px-0_Procyon_lotor_-_Raton_laveur_commun_%281%29.JPG");
            parkDistrict2.getOrganisms().add(parkDistrictOrganism21);
            parkDistrict2.getOrganisms().forEach(it -> it.setParkDistrict(parkDistrict2));

            ParkDistrict parkDistrict3 = new ParkDistrict();
            parkDistrict3.setName("The Mall & Literary Walk");
            parkDistrict3.setDescription("The Mall & Literary Walk");
            parkDistrict3.setImage("https://upload.wikimedia.org/wikipedia/commons/thumb/a/a2/The_Mall_%26_Literary_Walk%2C_Central_Park%2C_Manhattan%2C_NYC.JPG/359px-The_Mall_%26_Literary_Walk%2C_Central_Park%2C_Manhattan%2C_NYC.JPG");
            park.getDistricts().add(parkDistrict3);

            ParkDistrict parkDistrict4 = new ParkDistrict();
            parkDistrict4.setName("Strawberry Fields");
            parkDistrict4.setDescription("Strawberry Fields with the Dakota behind");
            parkDistrict4.setImage("https://upload.wikimedia.org/wikipedia/commons/4/4b/Strawberry_Fields_in_the_Central_Park_with_The_Dakota_behind.jpg");
            park.getDistricts().add(parkDistrict4);

            ParkDistrict parkDistrict5 = new ParkDistrict();
            parkDistrict5.setName("The Pond");
            parkDistrict5.setDescription("The Pond, looking south, with the Plaza Hotel in view");
            parkDistrict5.setImage("https://upload.wikimedia.org/wikipedia/commons/thumb/f/f3/Centralparkpond.jpg/358px-Centralparkpond.jpg");
            park.getDistricts().add(parkDistrict5);

            ParkDistrict parkDistrict6 = new ParkDistrict();
            parkDistrict6.setName("Bridge");
            parkDistrict6.setDescription("One of the park's bridges; no two are alike.");
            parkDistrict6.setImage("https://upload.wikimedia.org/wikipedia/commons/thumb/0/0a/Central_Park_New_York_City_New_York_23_cropped.jpg/800px-Central_Park_New_York_City_New_York_23_cropped.jpg");
            park.getDistricts().add(parkDistrict6);

            ParkDistrict parkDistrict7 = new ParkDistrict();
            parkDistrict7.setName("Bethesda Fountain");
            parkDistrict7.setDescription("Bethesda Fountain with the Loeb Boathouse in background");
            parkDistrict7.setImage("https://upload.wikimedia.org/wikipedia/commons/thumb/c/cd/Cplakehouse.JPG/797px-Cplakehouse.JPG");
            park.getDistricts().add(parkDistrict7);

            park.getDistricts().forEach(it -> it.setPark(park));

            parkService.save(park);
        };
    }

    @Bean
    public CommandLineRunner ecosystemDemo(EcosystemService ecosystemService) {
        return (args) -> {
            GlobalSearch globalSearch = new GlobalSearch("绥阳宽阔水国家级自然保护区");
            Page<Ecosystem> check = ecosystemService.findAll(globalSearch, new PageRequest(0, 20));
            if (check.hasContent()) {
                return;
            }

            Ecosystem ecosystem = new Ecosystem();
            ecosystem.setCreator("hanmeimei");
            ecosystem.setName("绥阳宽阔水国家级自然保护区");
            ecosystem.setAdministrativeLocation("贵州省遵义市绥阳县");
            ecosystem.setArea("26, 231公顷");
            ecosystem.setMaintained("原生性亮叶水青冈为主体的典型中亚热带常绿落叶阔叶林、国家重点保护动物黑叶猴、红腹锦鸡种群及其自然生境");
            ecosystem.setCategory("森林及野生动物类型");
            ecosystem.setAdministrativeDepartment("林业厅");
            ecosystem.setCreateDate("1989年");
            ecosystem.setCoordinate("北纬28°06′25″-28°19′25″；东经107°02′23″-107°14′09");
            ecosystem.setAdministrativeRegion("绥阳县的宽阔、黄杨、旺草、茅垭、青杠塘、枧坝6个镇的12个行政村");

            ecosystem.setCurrentLevel("国家级");
            ecosystem.setApprover("贵州省林业厅");
            ecosystem.setCurrentLevelApproveDate("2007年");

            ecosystem.setGeologyStructure("宽阔水区域主体构造格架形成于燕山褶皱造山运动之后，所属构造单元为扬子准地台的凤冈北北东向构造变形区西部，主要为黄鱼江复背斜，地质构造复杂，主要地质构造有褶皱和断裂。");
            ecosystem.setGeologyLithology("");
            ecosystem.setGeologyLandform("宽阔水位于黔北山地大娄山山脉东部斜坡地带，地势中部高、四周低，海拔在650-1 761m之间，其中最高峰为海拔1 762m的太阳山，西北部的塘村河谷底海拔650m，为全区的最低点。地形切割强烈，相对高差大。地貌除中南部的碎屑岩区以中低山谷地为主的侵蚀地貌外，多为喀斯特地貌，广泛分布于保护区东部、西部及北部，主要组合形态有峰丛峡谷、峰丛槽谷及峰丛洼地。");
            ecosystem.setGeologyHydrogeology("保护区为乌江一级支流芙蓉江的主要发源地，地形切割强烈，地表水文网密度大，主要支流有7条，次一级支流10条，干流长度达21．8km，以太阳山为分水线，向四周呈放射状流出，汇入乌江一级支流芙蓉江，山塘水库4座，河网密集，地下水资源丰富，水质良好。水质类型主要为HCO3-Ca·型、HCO3-Ca·Mg型或HC O3·S O4-Ca·Mg型。含水岩组可分为富水性强的碳酸盐岩裂隙管道水、富水性较弱的碎屑岩夹碳酸盐岩管道裂隙水和隔水层，其中以中上寒武统娄山关组和下奥陶统桐梓—红花园组为主的富水性强的碳酸盐岩裂隙管道水分布最广。");

            ecosystem.setClimate("保护区处于中亚热带湿润季风气侯区内，因处于日周较低中间相对窿起的高地上，气温低，云雾多，日照少，降雨充沛，具有低纬度山地季风湿润气候特点。宽阔水虽然纬度较低，太阳高度角较大，但云量多，阴雨天多，日照较少。年太阳总辐射值仅为3 349-3 767MJ/m2，比同纬度其他地区少，处在全国低值区内。\n" +
                    "该区年均气温11.7-15.2℃，气温的年平均垂直递减率为0.39℃/l00m，1月、4月、7月、10月分别为0.39、0.37、0.56、0.3CC/l00m；≥0℃积温，3 917-5 353℃；稳定通过10℃的持续日数，山麓为210-255天，山顶为178-215天；≥10℃积温3 262-4 861℃。山体下部极端最高气温达34.1℃，山顶的极端最低气温达-12.9℃。年降雨量在1 300-1 350mm，南坡高于北坡，相对湿度均在80％以上。气候垂直差异明显，1月、4月、7月、10月和年平均气温的垂直递减率分别为0.39、0.37、0.56、0.34和0.39℃/l00m；春、夏、秋、冬四季的平均气温垂直递减率分别为0.33、0.56、0.37和0.38℃/100 m。");
            ecosystem.setSoil("该保护区土壤可划分为铁铝土、淋溶土、初育土3个大土纲，湿暖铁铝土、湿暖淋溶土、土质初育土、石质初育土4个亚纲，黄壤、黄棕壤、石灰土、新积土、石质土和粗骨土7个土类，山地黄壤、山地黄棕壤、冲积土、黄色石灰土、棕色石灰土、酸性紫色土、酸性石质土、钙质石质土、酸性粗骨土9个亚类。在土类中，以黄棕壤面积最大，黄壤次之，石灰土较少，而其他土类则更少。根据中国土壤系统分类(2001)分类标准。7个土类相应的系统分类名称分别为富铝常湿富铁土等、铁质湿润淋溶土等、紫色土、钙质湿润淋溶土等、冲积新成土、石质正常新成土和石质湿润正常新成土等类型。\n" +
                    "该区内规律性土壤(地带性土壤)含黄壤和黄棕壤两大土类，分布在整个保护区的主要区域，其成土母岩为黄色、绿色砂岩、砂页岩、泥岩等，按照该区的生物、气候特性，有规律地分布，海拔1 400m以下为黄壤，主要集中分布于河谷地带；海拔1 400m以上为黄棕壤。集中分布在保护区的中部区域。非规律性土壤包括石灰土、紫色土、冲积土、石质土和粗骨土5大土类，尽管是由成土母质(岩)发育的幼年土壤，由于其处于一定的生物气候环境条件下。这些土类在发育过程中仍具有向地带性方向发展的过程，故也具有了一定的地带性土壤的特点，区内的黄色石灰土亚类，分布在海拔1 400m以下，主要分布区在西部、西南部河谷地区。棕色石灰土则分布在海拔1 400m以上的碳酸盐岩石分布区。紫色土集中分布在宽阔水中部地区红砂地附近，分布比较集中且面积较少。新积土主要分布在河流两侧平缓开阔处如河漫滩地等，表层有明显近期薄层沉积层。粗骨土、石质土分布在相对侵蚀容易的地形部位，如山脊、坡度较大等处。");

            ecosystem.setOrganismResourcesAnimal("该区动物资源丰富，有脊椎动物87科314种。其中鱼类4目8科30属35种；两栖纲2目9科17属27种；爬行纲3目8科19属31种；鸟类16目42科171种；哺乳动物7目20科40属50种。有国家一级保护动物4种，二级保护动物23种，珍稀濒危动物24种。蜘蛛17科44属66种对。洞穴动物17科44属66种。昆虫8目63科333种。");
            ecosystem.setOrganismResourcesForest("宽阔水自然保护区森林种子植物共有566属。其中木本植物260属，包括落叶乔木约72属，常绿乔木28属，灌木132属。木质藤本28属，草本307属。");
            ecosystem.setOrganismResourcesPlant("高等植物251科，774属，1 604种、亚种、变种、变型，其中，种子植物165科，566属，1 100种；蕨类植物27科，65属，178种，6变种、1变型；苔藓植物有59科，143属，319种和亚种、变种；大型真菌种类极为丰富，计201种，分属87属．41科。药用高等植物583种，隶属于121科，395属。种子植物1 100种，隶属于165科，566属，其中裸子植物为19种，隶属于6科，13属，被子植物1 083种(含亚种、变种、变型)， 隶属于159科，552属。");
            ecosystem.setOrganismResourcesVegeType("针叶林、阔叶林、 灌丛、竹林、经济林5个覆盖型组，森林覆盖率79.6％。");

            ecosystem.setTourismResources("1．地文景观 (1)山体类保护区内山体多，具有较高旅游价值的山体有太阳山、饭甑子、金钟山、插旗岩；(2)洞穴类保护区内具有较高旅游价值的洞穴有让水溶洞群、天星桥、蛮王洞；(3)峡谷类保护区风水垭口、马蹄溪至白石溪一带为河谷深切带，常形成深度在500m左右的槽谷、峡谷，兼而加上地下河、溪流、石山、次生林从而形成以峭壁、石山、流水、绿树、芳草、灵猴等为主要观赏对象的峡谷旅游资源，此类典型资源有十二背后、风水垭口、龙门峡、马蹄溪、一线天等。\n" +
                    "2．水文景观 保护区降水丰富，地质结构复杂，既有淙淙的溪流，又有碧波荡漾的水库，还有地下河，形成了丰富多彩的水文景观。通过本次考察，保护区水文景观主要有宽阔水库、茶场水库、林口瀑布、茶场泉、罗家沟、后山沟等。\n" +
                    "3．生物景观 保护区生物种类多，珍稀特有物种有一定的丰富度，植被类型多，主要景观林有常绿阔叶林、常绿落叶阔叶林、针叶林、针阔混交林等，具有较高观赏价值，且分布量较大的珍稀动物有黑叶猴、红腹锦鸡、弹琴蛙、白冠长尾雉等。主要观赏植物有珙桐、水青树、亮叶水青冈、香果树、鹅掌楸、福建柏、红豆杉、领春木、穗花杉、黄杉、厚朴、红花木莲、白辛树、玉兰、杜鹃、西南山茶、春兰、寒兰等。\n" +
                    "4．天象景观 保护区山峦重叠，山体立体气候差异大，天象资源丰富，有时辰季节气候变化的不同景致，亦有不同高度呈现的不同气候景观，保护区主要天象景观有朝晖、夕阳、雾海、雨淞、雪，此外，保护区春、夏、秋凉爽气候成为遵义地区的避暑胜地。\n" +
                    "5．人文景观 保护区世居汉族，异质性人文景观不多，区内典型的人文景观主要有山野村落、茶场。\n");

            ecosystem.setSocialEconomy("保护区居民收入相对较低，人均年纯收入1 400-1 700元(包括各种收入和粮食)，年人均纯收入1 550元。居民收入相对较高的是宽阔水茶场和黄杨镇金塘村，年人均纯收入在8 000元以上．最低的是白台村和茶坪村，人均纯收入仅800元和850元。经济收入来源主要通过传统农业生产、养殖和劳务输出获取。农业生产以种植业为主，主要经济作物有水稻、玉米、有烟叶、辣椒、萝卜、茶叶、竹笋、土豆、花生、红薯。但气温低，海拔高，物候不适应农作物生长，粮食产量低，水稻667m2产量在300-350kg之间，平均667m2产325kg(折合大米约150kg)；玉米667m2产量在150-200kg，平均667m2产175kg。按此计算保护区居民每年人均占有粮食510kg，按现有市场价折合人民币仅510元(含农业税)，加之野兽(主要是野猪、野兔、豪猪)对农作物破坏性大，种植成效更差，常形成投入高、收入少的格局，特别是田，如茅垭镇山河、茶坪村，宽阔镇白台村。粮食和经济作物远不能满足保护区居民生活的需要。");

            ecosystemService.save(ecosystem);
        };
    }

    @Bean
    public CommandLineRunner endangeredSpeciesDemo(EndangeredSpeciesService endangeredSpeciesService) {
        return (args) -> {
            GlobalSearch globalSearch = new GlobalSearch("东北虎");
            Page<EndangeredSpecies> check = endangeredSpeciesService.findAll(globalSearch, new PageRequest(0, 20));
            if (check.hasContent()) {
                return;
            }

            EndangeredSpecies endangeredSpecies = new EndangeredSpecies();
            endangeredSpecies.setCreator("hanmeimei");
            endangeredSpecies.setName("东北虎");
            endangeredSpecies.setConservationStatus("IUCN物种红色名录等级, 濒危Endangered（EN）");
            endangeredSpecies.setDistribution("俄罗斯,中国长白山");
            endangeredSpecies.setProtectionStatus("據俄羅斯統計，在哈巴羅夫斯克邊疆區和濱海邊疆區的山林中，1992年約有野生东北虎200只，2004年升至350只。特別在濱海邊疆區，东北虎的數量於過去十年中，從450只上升到500只。在嚴密的巡查下，非法偷獵者的行為得到了控制，但仍有不少虎崽死於路上交通事故。\n" +
                    "在中國長白山地區，據估計還有8-12隻左右的野生东北虎活動。黑龍江目前可能只有完達山脈和老爺嶺有野生东北虎活動，約有5-7隻。 黑龍江哈爾濱的東北虎林園（與橫道河子貓科動物飼養繁育中心是一個單位）是世界最大的東北虎人工飼養繁育基地。 2007年，該基地的东北虎數量已經由最初的8隻種虎，繁育到了1000餘只[2]。作為中國國家一級保護動物物種之一，中國政府為东北虎的保護製定了嚴格的管理辦法，一方面以法律規定禁止生產、銷售以虎為原料的中藥，如虎骨膏、虎骨酒等，堵塞應用市場，另外對牛羊被虎捕食的農民給予賠償。");
            endangeredSpecies.setDisturbances("较少人为干扰");

            endangeredSpeciesService.save(endangeredSpecies);
        };
    }

    @Bean
    public CommandLineRunner animalConservationDemo(AnimalConservationService animalConservationService) {
        return (args) -> {
            GlobalSearch globalSearch = new GlobalSearch("东北虎");
            Page<AnimalConservation> check = animalConservationService.findAll(globalSearch, new PageRequest(0, 20));
            if (check.hasContent()) {
                return;
            }

            AnimalConservation animalConservation = new AnimalConservation();
            animalConservation.setCreator("hanmeimei");
            animalConservation.setName("东北虎");

            AnimalConservationLocation animalConservationLocation1 = new AnimalConservationLocation();
            animalConservationLocation1.setPreserveLocation("xxx东北虎保育园");
            animalConservationLocation1.setConservationWay("xxx方法保育");
            animalConservationLocation1.setConservationStartDate("2011年");
            animalConservationLocation1.setConservationResult("存活");
            animalConservationLocation1.setQuantity("2只");
            animalConservationLocation1.setRecorder("路人甲");
            animalConservation.getLocation().add(animalConservationLocation1);
            animalConservation.getLocation().forEach(it -> it.setAnimalConservation(animalConservation));

            animalConservationService.save(animalConservation);
        };
    }

    @Bean
    public CommandLineRunner plantConservationDemo(PlantConservationService plantConservationService) {
        return (args) -> {
            GlobalSearch globalSearch = new GlobalSearch("光粒木槿");
            Page<PlantConservation> check = plantConservationService.findAll(globalSearch, new PageRequest(0, 20));
            if (check.hasContent()) {
                return;
            }

            PlantConservation plantConservation = new PlantConservation();
            plantConservation.setCreator("hanmeimei");
            plantConservation.setName("光粒木槿");
            plantConservation.setFamily("茜草科");
            plantConservation.setGenus("咖啡属");
            plantConservation.setSpecies("arabica");
            plantConservation.setLatin("arabica");

            Introduction introduction1 = new Introduction();
            introduction1.setIntroNo("00,1959,0001");
            introduction1.setAddYear("1998");
            introduction1.setAddMonth("12");
            introduction1.setCountry("中国");
            introduction1.setProvince("云南省");
            introduction1.setQuantity("2640粒");
            introduction1.setMaterialName("种子");
            introduction1.setRecorder("张远辉");
            plantConservation.getIntroduction().add(introduction1);
            plantConservation.getIntroduction().forEach(it -> it.setPlantConservation(plantConservation));

            Planting planting1 = new Planting();
            planting1.setIntroNo("00,1959,0001");
            planting1.setCoordinate("28°06′25″-28°19′25″；107°02′23″-107°14′09″");
            planting1.setAltitude("560米");
            planting1.setQuantity("999粒");
            planting1.setPlantingUnit("贵州动植物保育研究所");
            planting1.setPlantingDate("2000年");
            planting1.setNotes("中国热带植物（种质）资源收集区 C40");
            plantConservation.getPlanting().add(planting1);
            plantConservation.getPlanting().forEach(it -> it.setPlantConservation(plantConservation));

            PhenologyRecord phenologyRecord1 = new PhenologyRecord();
            phenologyRecord1.setIntroNo("00,1959,0001");
            phenologyRecord1.setLocation("中国热带植物（种质）资源收集区 C40");
            phenologyRecord1.setObserver("管策仁");
            phenologyRecord1.setObserveYear("2008年");
            phenologyRecord1.setPhaseOne("");
            phenologyRecord1.setPhaseTwo("");
            phenologyRecord1.setPhaseThree("");
            phenologyRecord1.setPhaseFour("");
            phenologyRecord1.setPhaseFive("");
            phenologyRecord1.setPhaseSix("");
            plantConservation.getPhenologyRecords().add(phenologyRecord1);
            plantConservation.getPhenologyRecords().forEach(it -> it.setPlantConservation(plantConservation));

            PropagationCultivation propagationCultivation1 = new PropagationCultivation();
            propagationCultivation1.setIntroNo("00,1959,0001");
            propagationCultivation1.setMaterialType("苗");
            propagationCultivation1.setMaterialQuantity("1");
            propagationCultivation1.setGrowthSituation("良好");
            propagationCultivation1.setRecorder("张远辉");
            propagationCultivation1.setCultivateDate1("2015年01月19日");
            propagationCultivation1.setCultivateDate2("2016年01月19日");
            propagationCultivation1.setCultivateDate3("2017年01月19日");
            propagationCultivation1.setCultivateNumber("1");
            propagationCultivation1.setCultivateSubstance("园土+树皮+草碳土+珍珠岩");
            propagationCultivation1.setSurvivalRate("100%");
            propagationCultivation1.setSurvive1("1");
            propagationCultivation1.setSurvive2("1");
            propagationCultivation1.setSurvive3("1");
            propagationCultivation1.setFillingDate("2017年01月19日");
            plantConservation.getPropagationCultivation().add(propagationCultivation1);
            plantConservation.getPropagationCultivation().forEach(it -> it.setPlantConservation(plantConservation));

            plantConservationService.save(plantConservation);
        };
    }

    @Bean
    public CommandLineRunner vegetationDemo(VegetationService vegetationService) {
        return (args) -> {
            GlobalSearch globalSearch = new GlobalSearch("东亚针叶林");
            Page<Vegetation> check = vegetationService.findAll(globalSearch, new PageRequest(0, 20));
            if (check.hasContent()) {
                return;
            }

            Vegetation vegetation = new Vegetation();
            vegetation.setName("东亚针叶林");
            vegetation.setCategory("自然植被");
            vegetation.setCategoryA1("A1");
            vegetation.setCategoryA2("A1");
            vegetation.setCategoryA3("A1");
            vegetation.setCategoryA4("A1");
            vegetation.setCategoryA5("A1");
            vegetation.setCategoryA6("A1");
            vegetation.setCommunityCharacteristics("群落特征 balabala");
            vegetation.setHabitatAgrotype("生境特点 xxx");
            vegetation.setHabitatAltitude("生境特点 xxx");
            vegetation.setHabitatPrecipitation("生境特点 xxx");
            vegetation.setHabitatTemperature("生境特点 xxx");
            vegetation.setCreator("hanmeimei");

            ListQuadrat listQuadrat = new ListQuadrat();
            listQuadrat.setLocation("梵净山，肖家河");
            listQuadrat.setCoordinate("东经120°12′，北纬30°16′");
            listQuadrat.setAltitude("1540米");
            listQuadrat.setGradient("28");
            listQuadrat.setExposure("NE5");

            listQuadrat.setQuadratYear("2007");
            listQuadrat.setTreeLayerArea("样方面积（20 x 30）");
            listQuadrat.setTreeLayerCoverage("80%");
            listQuadrat.setFieldLayerArea("样方面积（5 x 5）");
            listQuadrat.setFieldLayerCoverage("65%");
            vegetation.getListQuadrat().add(listQuadrat);

            ListQuadratItem item1 = new ListQuadratItem();
            item1.setName("枫香");
            item1.setLatin("Liquidambar formosama");
            item1.setItemlevel("Ap");
            item1.setTree("3");
            item1.setCoverage("55");
            item1.setHeightAvg("25");
            item1.setHeightMax("30");
            item1.setDbhAvg("25");
            item1.setDbhMax("45");
            item1.setCanopyAvg("10");
            item1.setCanopyMax("15");
            item1.setFlourish("盛");
            item1.setBiotype("落叶");
            listQuadrat.getItems().add(item1);

            ListQuadratItem item2 = new ListQuadratItem();
            item2.setName("巴东栋");
            item2.setLatin("Quercus engleriana");
            item2.setItemlevel("Ap");
            item2.setTree("2");
            item2.setCoverage("20");
            item2.setHeightAvg("15");
            item2.setHeightMax("18");
            item2.setDbhAvg("20");
            item2.setDbhMax("28");
            item2.setCanopyAvg("7");
            item2.setCanopyMax("8");
            item2.setFlourish("盛");
            item2.setBiotype("常绿");
            listQuadrat.getItems().add(item2);

            vegetation.getListQuadrat().forEach(list -> {
                list.setVegetation(vegetation);
                list.getItems().forEach(item -> item.setListQuadrat(list));
            });

            vegetationService.save(vegetation);
        };
    }

    @Bean
    public CommandLineRunner productDemo(ProductService productService) {
        return (args) -> {
            GlobalSearch globalSearch = new GlobalSearch("水城红心猕猴桃");
            Page<Product> check = productService.findAll(globalSearch, new PageRequest(0, 20));
            if (check.hasContent()) {
                return;
            }

            Product product = new Product();

            product.setCreator("xiaoming");
            product.setName("水城红心猕猴桃");
            product.setCategory("水果");
            product.setBrand("无");
            product.setBarcode("无");
            product.setTargetGroup("所有人群");
            product.setSpecification("80-110克（单果）");
            product.setIngredients("鲜果");
            product.setNutrition("富含有9种矿物质，10种维生素。每100克猕猴桃所含的营养指数为16。其中，VC是柳橙的1.7倍，纤维是菠菜的1.7倍。VE是樱桃的2倍，钙是香蕉的2.5倍。");
            product.setFeature("富含维C");
            product.setDescription("无");

            ProductOrganism productOrganism = new ProductOrganism();
            productOrganism.setName("中华猕猴桃");
            productOrganism.setOrganismId("1");
            product.getOrganisms().add(productOrganism);

            ProductImage productImage = new ProductImage();
            productImage.setUrl("http://cdn.ap.shiant.com/images/73/73a2e1a797254867aac7f7e40fecd1e6.jpg");
            product.getImages().add(productImage);

            product.getOrganisms().forEach(it -> it.setProduct(product));
            product.getImages().forEach(it -> it.setProduct(product));

            productService.save(product);
        };
    }

    @Bean
    public CommandLineRunner enterpriseDemo(EnterpriseService enterpriseService) {
        return (args) -> {
            GlobalSearch globalSearch = new GlobalSearch("水城红心猕猴桃");
            Page<Enterprise> check = enterpriseService.findAll(globalSearch, new PageRequest(0, 20));
            if (check.hasContent()) {
                return;
            }

            Enterprise enterprise = new Enterprise();

            enterprise.setCreator("xiaoming");

            enterprise.setName("水城县东部农业产业园区管理委员会");
            enterprise.setLegalPerson("张辉");
            enterprise.setPhone("13809429508");
            enterprise.setEmail("scmhtyqb@163.com");
            enterprise.setAddress("六盘水水城县双水街道办事处");

            EnterpriseProduct enterpriseProduct = new EnterpriseProduct();
            enterpriseProduct.setProductId("1");
            enterpriseProduct.setName("水城红心猕猴桃");
            enterpriseProduct.setBarcode("无");
            enterpriseProduct.setCategory("水果");
            enterpriseProduct.setDescription("无");
            enterprise.getProducts().add(enterpriseProduct);

            Entrepreneur entrepreneur = new Entrepreneur();
            entrepreneur.setName("张辉");
            entrepreneur.setSex("男");
            entrepreneur.setDescription("无");
            enterprise.getEntrepreneurs().add(entrepreneur);

            enterprise.getEntrepreneurs().forEach(it -> it.setEnterprise(enterprise));
            enterprise.getProducts().forEach(it -> it.setEnterprise(enterprise));

            enterpriseService.save(enterprise);
        };
    }
}
